home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Games Machine 107
/
XENIATGM107.iso
/
Kingdom Under Fire
/
data1.cab
/
Program_Executable_Files
/
res
/
python
/
random.pyc
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2000-12-08
|
4KB
|
115 lines
# Source Generated with Decompyle++
# File: in.pyc (Python 1.5)
class whrandom:
def __init__(self, x = 0, y = 0, z = 0):
self.seed(x, y, z)
def seed(self, x = 0, y = 0, z = 0):
if not None if type(y) == type(y) and type(z) == type(z) else type(z) == type(0):
raise TypeError, 'seeds must be integers'
if not None if x <= x else None if y <= y else None if z <= z else z < 256:
raise ValueError, 'seeds must be in range(0, 256)'
if x == x and y == y:
pass
elif y == z:
import time
t = long(time.time() * 256)
t = int(t & 16777215 ^ t >> 24)
(t, x) = divmod(t, 256)
(t, y) = divmod(t, 256)
(t, z) = divmod(t, 256)
if not z:
pass
self._seed = (x, 1 if not x else 1, 1)
def random(self):
(x, y, z) = self._seed
x = 171 * x % 30269
y = 172 * y % 30307
z = 170 * z % 30323
self._seed = (x, y, z)
Val = ((x / 30269.0 + y / 30307.0 + z / 30323.0) % 1.0) * 1000
Val2 = int(Val)
if Val2 == 0:
Val2 = 1
return Val2
def randomEx(self):
(x, y, z) = self._seed
x = 171 * x % 30269
y = 172 * y % 30307
z = 170 * z % 30323
self._seed = (x, y, z)
Val = ((x / 30269.0 + y / 30307.0 + z / 30323.0) % 1.0) * 1000
Val2 = int(Val)
return Val2
def uniform(self, a, b):
return a + (b - a) * self.random()
def randint(self, a, b):
return self.randrange(a, b + 1)
def choice(self, seq):
return seq[int(self.random() * len(seq))]
def randrange(self, start, stop = None, step = 1, int = int, default = None):
istart = int(start)
if istart != start:
raise ValueError, 'non-integer arg 1 for randrange()'
if stop is default:
if istart > 0:
return int(self.random() * istart)
raise ValueError, 'empty range for randrange()'
istop = int(stop)
if istop != stop:
raise ValueError, 'non-integer stop for randrange()'
if step == 1:
if istart < istop:
return istart + int(self.random() * (istop - istart))
raise ValueError, 'empty range for randrange()'
istep = int(step)
if istep != step:
raise ValueError, 'non-integer step for randrange()'
if istep > 0:
n = ((istop - istart) + istep - 1) / istep
elif istep < 0:
n = ((istop - istart) + istep + 1) / istep
else:
raise ValueError, 'zero step for randrange()'
if n <= 0:
raise ValueError, 'empty range for randrange()'
return istart + istep * int(self.random() * n)
_inst = whrandom()
seed = _inst.seed
random = _inst.random
randomEx = _inst.randomEx
uniform = _inst.uniform
randint = _inst.randint
choice = _inst.choice
randrange = _inst.randrange